/*
 * @Description: vxe-table按需加载文件
 * @Date:
 * @LastEditTime:
 * @FilePath:
 */
// 可选组件
import {
  VxeUI,
  VxeButton,
  VxeButtonGroup,
  VxeDrawer,
  VxeForm,
  VxeFormGroup,
  VxeFormItem,
  VxeIcon,
  VxeLoading,
  VxeModal,
  VxePager,
  VxePrint,
  VxeTooltip,
  VxeUpload,
  VxePulldown,
  VxeList,
  VxeInput,
  VxeSelect,
  VxeCheckbox,
  VxeNumberInput,
  VxeRadioGroup
} from "vxe-pc-ui";
import { VxeTable, VxeColumn, VxeColgroup, VxeGrid, VxeToolbar } from "vxe-table";
import domZIndex from "dom-zindex";
// 导入主题变量，也可以重写主题变量
import "vxe-table/styles/cssvar.scss";
import "vxe-pc-ui/styles/cssvar.scss";

// 导入默认的语言
import zhCN from "vxe-pc-ui/lib/language/zh-CN";

VxeUI.setI18n("zh-CN", zhCN);
VxeUI.setLanguage("zh-CN");

// 可选组件
export function lazyVxeUI(app) {
  app.use(VxeButton);
  app.use(VxeButtonGroup);
  app.use(VxeDrawer);
  app.use(VxeForm);
  app.use(VxeFormGroup);
  app.use(VxeFormItem);
  app.use(VxeIcon);
  app.use(VxeLoading);
  app.use(VxeModal);
  app.use(VxePager);
  app.use(VxePrint);
  app.use(VxeTooltip);
  app.use(VxeUpload);
  app.use(VxePulldown);
  app.use(VxeList);
  app.use(VxeInput);
  app.use(VxeSelect);
  app.use(VxeCheckbox);
  app.use(VxeNumberInput);
  app.use(VxeRadioGroup);
}

export function lazyVxeTable(app) {
  app.use(VxeTable);
  app.use(VxeColumn);
  app.use(VxeColgroup);
  app.use(VxeGrid);
  app.use(VxeToolbar);
}

VxeUI.setConfig({
  // size: null, // 全局尺寸
  // zIndex: 999, // 全局 zIndex 起始值，如果项目的的 z-index 样式值过大时就需要跟随设置更大，避免被遮挡；新版本可以使用 dom-zindex 共享配置
  // version: 1, // 版本号，对于某些带数据缓存的功能有用到，上升版本号可以用于重置数据

  emptyCell: "　",
  table: {
    showHeader: true,
    delayHover: 250,
    autoResize: true,
    padding: true,
    minHeight: 144,
    // keepSource: false,
    // showOverflow: null,
    // showHeaderOverflow: null,
    // showFooterOverflow: null,
    // resizeInterval: 500,
    // size: null,
    // zIndex: null,
    // stripe: false,
    // border: false,
    // round: false,
    // emptyText: '暂无数据',
    // emptyRender: {
    //   name: ''
    // },
    // rowConfig: {
    //   keyField: '_X_ROW_KEY' // 行数据的唯一主键字段名
    // },
    resizeConfig: {
      // refreshDelay: 250
    },
    resizableConfig: {
      dragMode: "auto",
      showDragTip: true
    },
    radioConfig: {
      // trigger: 'default'
      strict: true
    },
    rowDragConfig: {
      showIcon: true
    },
    columnDragConfig: {
      showIcon: true
    },
    checkboxConfig: {
      // trigger: 'default',
      strict: true
    },
    tooltipConfig: {
      enterable: true
    },
    validConfig: {
      showMessage: true,
      autoClear: true,
      autoPos: true,
      message: "inline",
      msgMode: "single",
      theme: "beautify"
    },
    columnConfig: {
      maxFixedSize: 4
    },
    // menuConfig: {
    //   visibleMethod () {}
    // },
    customConfig: {
      allowVisible: true,
      allowResizable: true,
      allowFixed: true,
      allowSort: true,
      showFooter: true,
      placement: "top-right",
      //  storage: false,
      //  checkMethod () {},
      modalOptions: {
        showMaximize: true,
        mask: true,
        lockView: true,
        resize: true,
        escClosable: true
      }
    },
    sortConfig: {
      // remote: false,
      // trigger: 'default',
      // orders: ['asc', 'desc', null],
      // sortMethod: null,
      showIcon: true,
      iconLayout: "vertical"
    },
    filterConfig: {
      // remote: false,
      // filterMethod: null,
      showIcon: true
    },
    treeConfig: {
      rowField: "id",
      parentField: "parentId",
      childrenField: "children",
      hasChildField: "hasChild",
      mapChildrenField: "_X_ROW_CHILD",
      indent: 20,
      showIcon: true
    },
    expandConfig: {
      // trigger: 'default',
      showIcon: true
    },
    editConfig: {
      // mode: 'cell',
      showIcon: true,
      showAsterisk: true,
      autoFocus: true
    },
    importConfig: {
      _typeMaps: {
        csv: 1,
        html: 1,
        xml: 1,
        txt: 1
      }
    },
    exportConfig: {
      _typeMaps: {
        csv: 1,
        html: 1,
        xml: 1,
        txt: 1
      }
    },
    printConfig: {},
    mouseConfig: {
      extension: true
    },
    keyboardConfig: {
      isEsc: true
    },
    areaConfig: {
      autoClear: true,
      selectCellByHeader: true,
      selectCellByBody: true
    },
    clipConfig: {
      isCopy: true,
      isCut: true,
      isPaste: true
    },
    fnrConfig: {
      isFind: true,
      isReplace: true
    },
    scrollX: {
      // enabled: false,
      gt: 60
      // oSize: 0
    },
    scrollY: {
      // enabled: false,
      gt: 100
      // oSize: 0
    }
  },
  // export: {
  //   types: {}
  // },
  grid: {
    // size: null,
    // zoomConfig: {
    //   escRestore: true
    // },
    formConfig: {
      enabled: true
    },
    pagerConfig: {
      enabled: true
      // perfect: false
    },
    toolbarConfig: {
      enabled: true
      // perfect: false
    },
    proxyConfig: {
      enabled: true,
      autoLoad: true,
      showResponseMsg: true,
      showActiveMsg: true,
      props: {
        list: null,
        result: "result",
        total: "page.total",
        message: "message"
      }
      // beforeItem: null,
      // beforeColumn: null,
      // beforeQuery: null,
      // afterQuery: null,
      // beforeDelete: null,
      // afterDelete: null,
      // beforeSave: null,
      // afterSave: null
    }
  },
  toolbar: {
    // size: null,
    // import: {
    //   mode: 'covering'
    // },
    // export: {
    //   types: ['csv', 'html', 'xml', 'txt']
    // },
    // buttons: []
  }
});
VxeUI.setIcon({
  // table
  TABLE_SORT_ASC: "vxe-icon-caret-up",
  TABLE_SORT_DESC: "vxe-icon-caret-down",
  TABLE_FILTER_NONE: "vxe-icon-funnel",
  TABLE_FILTER_MATCH: "vxe-icon-funnel",
  TABLE_EDIT: "vxe-icon-edit",
  TABLE_TITLE_PREFIX: "vxe-icon-question-circle-fill",
  TABLE_TITLE_SUFFIX: "vxe-icon-question-circle-fill",
  TABLE_TREE_LOADED: "vxe-icon-spinner roll",
  TABLE_TREE_OPEN: "vxe-icon-caret-right rotate90",
  TABLE_TREE_CLOSE: "vxe-icon-caret-right",
  TABLE_EXPAND_LOADED: "vxe-icon-spinner roll",
  TABLE_EXPAND_OPEN: "vxe-icon-arrow-right rotate90",
  TABLE_EXPAND_CLOSE: "vxe-icon-arrow-right",
  TABLE_CHECKBOX_CHECKED: "vxe-icon-checkbox-checked-fill",
  TABLE_CHECKBOX_UNCHECKED: "vxe-icon-checkbox-unchecked",
  TABLE_CHECKBOX_INDETERMINATE: "vxe-icon-checkbox-indeterminate-fill",
  TABLE_RADIO_CHECKED: "vxe-icon-radio-checked-fill",
  TABLE_RADIO_UNCHECKED: "vxe-icon-radio-unchecked",
  TABLE_CUSTOM_SORT: "vxe-icon-drag-handle",
  TABLE_MENU_OPTIONS: "vxe-icon-arrow-right",
  TABLE_DRAG_ROW: "vxe-icon-drag-handle",
  TABLE_DRAG_COLUMN: "vxe-icon-drag-handle",

  // toolbar
  TOOLBAR_TOOLS_REFRESH: "vxe-icon-repeat",
  TOOLBAR_TOOLS_REFRESH_LOADING: "vxe-icon-repeat roll",
  TOOLBAR_TOOLS_IMPORT: "vxe-icon-upload",
  TOOLBAR_TOOLS_EXPORT: "vxe-icon-download",
  TOOLBAR_TOOLS_PRINT: "vxe-icon-print",
  TOOLBAR_TOOLS_FULLSCREEN: "vxe-icon-fullscreen",
  TOOLBAR_TOOLS_MINIMIZE: "vxe-icon-minimize",
  TOOLBAR_TOOLS_CUSTOM: "vxe-icon-custom-column",
  TOOLBAR_TOOLS_FIXED_LEFT: "vxe-icon-fixed-left",
  TOOLBAR_TOOLS_FIXED_LEFT_ACTIVE: "vxe-icon-fixed-left-fill",
  TOOLBAR_TOOLS_FIXED_RIGHT: "vxe-icon-fixed-right",
  TOOLBAR_TOOLS_FIXED_RIGHT_ACTIVE: "vxe-icon-fixed-right-fill"
});

domZIndex.setCurrent(1000);
